import { createRequestTypes } from '@UTILS/reduxHelper'
import { ProfileITF, UserITF, WeChatITF } from '@INTERFACES/user'
import { ProfileActionITF } from '@REDUXITF/profile'
import { Action } from 'redux'
import { ACQUIRE_CHANNEL_ENUM } from '@CONSTANTS/profile'
export const INIT_USER = createRequestTypes('INIT_USER')
export const UPDATE_USER_BY_WECHAT_INFO = createRequestTypes('UPDATE_USER_BY_WECHAT_INFO')
export const UPDATE_PROFILE = createRequestTypes('UPDATE_PROFILE')
export const GET_PROFILE = createRequestTypes('GET_PROFILE')
export const UPDATE_PROFILE_AVATAR = createRequestTypes('UPDATE_PROFILE_AVATAR')
export const SET_ACQUIRE_CHANNEL = createRequestTypes('SET_ACQUIRE_CHANNEL')

export default {
  dispatchInitUser(user: UserITF): ProfileActionITF {
    return {
      type: INIT_USER.REQUEST,
      user
    }
  },
  dispatchUpdateProfileByWeChat(params: WeChatITF): ProfileActionITF {
    return {
      type: UPDATE_USER_BY_WECHAT_INFO.REQUEST,
      params,
    }
  },
  dispatchUpdateProfile(params: ProfileITF) : ProfileActionITF {
    return {
      type: UPDATE_PROFILE.REQUEST,
      params,
    }
  },
  dispatchGetProfile() : Action {
    return {
      type: GET_PROFILE.REQUEST,
    }
  },
  dispatchUpdateAvatar() : Action {
    return {
      type: UPDATE_PROFILE_AVATAR.REQUEST,
    }
  },
  dispatchSetAcquireChannel(acquireChannel: ACQUIRE_CHANNEL_ENUM): ProfileActionITF {
    return {
      type: SET_ACQUIRE_CHANNEL.REQUEST,
      acquireChannel,
    }
  },
}
